import { createRouter, createWebHistory } from "vue-router";

const routes = [
    {
        path: "/",
        redirect: '/naming'
    },
    {
        path: "/naming",
        name: "naming",
        meta: {
            title: 'AI起名'
        },
        component: () => import("@/views/NameGenerator.vue"),
    },
];

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes,
});

// 导航守卫，用于动态设置页面的标题  
router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title;
    }
    next();
});

export default router;
